package pages;
//
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

public class LoginPage {

	private WebDriver driver;
	
	@FindBy(using = "Email")
	public WebElement useremail;
	
	public LoginPage(WebDriver driver){
		PageFactory.initElements(driver, this);
		this.driver = driver;
	}
	
	public HomePage login (String username, String userpassword){
		driver.get("http://gmail.com");
		useremail.sendKeys(username);
		//driver.findElement(By.id("Email")).sendKeys(username);
		driver.findElement(By.id("Passwd")).sendKeys(userpassword);
		driver.findElement(By.id("signIn")).click();
		return new HomePage(driver);
	}
	
	public void loginError (String username, String userpassword){
		driver.get("gmail.com");
		driver.findElement(By.id("Email")).sendKeys(username);
		driver.findElement(By.id("Password")).sendKeys(userpassword);
		driver.findElement(By.id("signIn")).click();
	}
}
